use diesel::{Insertable, Queryable};
use serde::{Deserialize, Serialize};

use crate::schema::todo;

#[derive(Queryable, Serialize)]
// #[diesel(table_name = crate::schame::todo)]
// #[diesel(check_for_backend(diesel::sqlite::Sqlite))]
pub struct Todo {
  pub id: i32,
  pub name: String,
  pub email: String,
  pub create_at: String,
}

#[derive(Deserialize, Insertable)]
#[diesel(table_name = todo)] // 需引入 crate::schema::todo
pub struct NewTodo {
  pub name: String,
  pub email: String,
}

#[derive(Queryable, Deserialize)]
pub struct UpdateTodo {
  pub name: String,
  pub email: String,
  #[serde(skip_deserializing)]
  pub create_at: String,
}
